package db

import (
	"fmt"

	"go.mongodb.org/mongo-driver/bson"
	. "starsine.cn/appTpl/cmn/defs"
)

var logDB *LogDB = nil

func Start(appCtxt *AppContext) error {
	logDB = CreateLogDB(appCtxt)
	if err := logDB.Start(); err != nil {
		return fmt.Errorf("db.logDB.Start fail, err: %s", err)
	}

	return nil
}

func GetOne(k, v string) *bson.M {
	return logDB.db.GetOne(k, v)
}

func InsertOne(doc interface{}) error {
	return logDB.db.InsertOne(doc)
}

func InsertMany(docs []interface{}) error {
	return logDB.db.InsertMany(docs)
}
